TRUNC_UDINT block

Short summary

Name

TRUNC_UDINT

→POU type

→function

Category

Standard (safe), Convert

Conform to →IEC-standard

(tick) no restrictions, but: (info) implementer-specific realization; see "Functionality"

Graphical interface

Available since

version 1.27.0 (for Neuron Power Engineer) - initial variant

version 3.1.0 (for library Standard) – For inputs of data type REAL, the optimized float variant of the C-runtime is used. Compared to previous versions, it is possible that (marginal) other results are returned within the threshold range of the block. 

version 3.8.0 (for library Standard (safe)): block provided in this library

Functionality

The mathematical function trunc is called:

The decimal portion of the floating-point number connected to input IN  is truncated (there is no rounding). The block returns the integer value as UDINT value.

Implementer-specific realization

The IEC-standard defines that it is an error when the connected value is not within the range of values overlapping for the data type of the input and for the data type of the return value as well as that the behavior in the case of such an error is implementer specific. The general behavior of the TRUNC blocks inNeuron Power Engineer is as follows: The non-overlapping value range is not considered to be an error. The return value of the block depends on the compiler and target system (see "Effects of the compiler settings on the execution" for details).

Inputs, return value

 

Identifier

→Data type

Description

Inputs:

IN

REAL, LREAL
(corresponds to →generic data type ANY_REAL)

value to truncate

Return value:

UDINT

 

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Example for usage within ST-editor

PROGRAM Test
   VAR
      result1, result2, result3, result4 : UDINT;
   END_VAR
   result1 := TRUNC_UDINT(2.8);     (* The variable 'result1' evaluates to '2'. *)
   result2 := TRUNC_UDINT(2.5);     (* The variable 'result2' evaluates to '2'. *)
   result3 := TRUNC_UDINT(2.01);    (* The variable 'result3' evaluates to '2'. *)
   result4 := TRUNC_UDINT(2.0);     (* The variable 'result4' evaluates to '2'. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.